package ml.uuku.oschub;

import com.loopj.android.http.AsyncHttpClient;

import ml.uuku.oschub.api.ApiHttpClient;
import ml.uuku.oschub.base.BaseApplication;
import ml.uuku.oschub.util.TLog;

/**
 * @author <a href=http://my.oschina.net/uuku>uuku</a>
 * @version V0.1
 */
public class AppContext extends BaseApplication {

    public static final int PAGE_SIZE = 20;// 默认分页大小
    private static AppContext instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        init();
    }

    public static AppContext getInstance(){
        return instance;
    }

    private void init() {
        // 初始化网络请求
        AsyncHttpClient client = new AsyncHttpClient();
        ApiHttpClient.setHttpClient(client);
        // Log控制器
        TLog.DEBUG = BuildConfig.DEBUG;
    }

    /**
     * 是否是首次启动
     */
    public static boolean isFirstStart() {
        return getPreferences().getBoolean(AppConfig.KEY_FIRST_START, false);
    }

    /**
     * 夜间模式
     */
    public static boolean getNightModeSwitch() {
        return getPreferences().getBoolean(AppConfig.KEY_NIGHT_MODE_SWITCH, false);
    }

    /**
     * 设置夜间模式
     */
    public static void setNightModeSwitch(boolean on) {

    }
}
